package com.cjet.nissan.room

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

@Database(entities = [NTDS::class], version = 1, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {


    abstract val appDatabaseDao: AppDatabaseDao

    companion object {

        @Volatile
        private var INSTA: AppDatabase? = null

        fun getInstance(context: Context): AppDatabase {
            synchronized(this) {
                var instance = INSTA

                if (instance == null) {
                    instance = Room.databaseBuilder(
                        context,
                        AppDatabase::class.java,
                        "user_collect_table"
                    )
                        .fallbackToDestructiveMigration()
                        .build()
                    INSTA = instance
                }
                return instance
            }
        }
    }


}